#include "ZigbusAddressNeed.h"

ZigbusAddressNeed::ZigbusAddressNeed()
    : ZigbusItem(-1, ADDR_NEED_SIZE)
{
}

ZigbusAddressNeed::ZigbusAddressNeed(int value)
    : ZigbusItem(value, ADDR_NEED_SIZE)
{
    if(value != 0x00 && value != 0x01)
        setValue(-1); //invalid
}

ZigbusAddressNeed::ZigbusAddressNeed(bool needed)
    : ZigbusItem(-1, ADDR_NEED_SIZE)
{
    if(needed)
        setValue(1);
    else
        setValue(0);
}

ZigbusAddressNeed::ZigbusAddressNeed(const ZigbusAddressNeed &other)
    : ZigbusItem(other)
{
}

QString ZigbusAddressNeed::text() const
{
    if(getValue() <= 0) return "config needed";
    return "address needed";
}

ZigbusAddressNeed ZigbusAddressNeed::INVALID()
{
    ZigbusAddressNeed addr;
    addr.setValue(-1);
    return addr;
}
